# # 1，导入pyecharts包
# from pyecharts import options as opts
# from pyecharts.charts import Pie
# from pyecharts.faker import Faker
#
# # 2，准备相应数据，二维列表
# lst = [['华为',1200],['荣耀',1000],['苹果',6200],['小米',900]]
# c = (
#     Pie()
#     # .add("", [list(z) for z in zip(Faker.choose(), Faker.values())])
#     .add("", lst)
#     .set_global_opts(title_opts=opts.TitleOpts(title="2024年北京手机出库量占比图"))
#     .set_series_opts(label_opts=opts.LabelOpts(formatter="{b}: {c}"))
#     .render("phone.html")
# )
# # print([list(z) for z in zip(Faker.choose(), Faker.values())])

# Pie-玫瑰图示例
from pyecharts import options as opts
from pyecharts.charts import Pie
from pyecharts.faker import Faker

# 准备数据
lst = [['华为',1200],['荣耀',1000],['苹果',6200],['小米',900]]

v = Faker.choose()
c = (
    Pie()
    .add(
        "",
        lst,
        radius=["30%", "55%"],
        center=["50%", "50%"],
        rosetype="area",
    )
    .set_global_opts(title_opts=opts.TitleOpts(title="2024年北京手机出库量占比图"))
    .render("pie_rosetype.html")
)

print([list(z) for z in zip(v, Faker.values())])